﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using FXnaAppBase;

using FXnaWpfBase;

using System.Windows;

using System.Windows.Input;


using System.Windows.Controls;

using Microsoft.Win32;

using DotSpatial.Data;


namespace FXnaAppBaseWpf
{
    public class BitmapCollecionViewModel:MDTVIViewModel
    {

        public BitmapCollecionViewModel(MDTVIViewModel parent,BitmapCollection images)
            : base(parent)
        {

            this._imageCollection = images;

            this.LoadChildren();

            //右键系统

            _contextMenu = new System.Windows.Controls.ContextMenu();

            MenuItem mi = new MenuItem();
            mi.Header = "添加";

            mi.Command = AppBaseCommands.AddImage;
          

            this._contextMenu.Items.Add(mi);


            //集合事件

            this._imageCollection.ImageAdded += new EventHandler(_imageCollection_ImageAdded);

            this._imageCollection.ImageRemoved += new EventHandler(_imageCollection_ImageRemoved);
 

        }



        void _imageCollection_ImageRemoved(object sender, EventArgs e)
        {
            this.Children.Clear();
            this.LoadChildren();


        }

        void _imageCollection_ImageAdded(object sender, EventArgs e)
        {
            this.Children.Clear();
            this.LoadChildren();

        }


        public override string Desc
        {
            get
            {
                return "位图集合";
            }
        }



        BitmapCollection _imageCollection;

        public BitmapCollection ImageCollection
        {
            get { return _imageCollection; }
            set { _imageCollection = value; }
        }


        protected override void LoadChildren()
        {
            base.LoadChildren();


            foreach (Bitmap img in this._imageCollection.Images)
            {

                BitMapViewModel vm = new BitMapViewModel(this,img);

                this.Children.Add(vm);
              
                
            }

        }


       
       

    }
}
